<template>
  <div>
    <!-- top头部 -->
    <div class="dwz-box"></div>
    <div class="head-container">
      <div class="wrap">
        <!-- logo -->
        <a class="logo" href="#" rel="nofollow"></a>
        <!-- logo End -->
        <!-- 网站导航 -->
        <div class="nav-item-box">
          <a href="/" class="pc-yxw-nav">首页</a>
          <a href="#" class="pc-yxw-nav">视频课程</a>
          <a href="#" class="pc-yxw-nav" rel="nofollow">会员特权</a>
          <a href="#" class="pc-yxw-nav">干货分享</a>
          <a class="pc-yxw-nav btn1" style="cursor:pointer;">手机学课</a>
        </div>
        <!-- 网站导航 End -->

        <!-- 课程搜索 -->
        <div class="ysearch-box">
          <form method="post" name="f1" action="#plus/search.php" onsubmit="return checkSearchForm()">
            <input type="hidden" name="kwtype" value="0">
            <input type="hidden" id="driverId" name="channeltype" value="17">
            <input type="text" class="yfixtext" id="keyword" name="keyword" placeholder="搜索课程" autocomplete="off">
            <input type="submit" class="fixsbmt" value="">
          </form>
        </div>
        <!-- 课程搜索 End -->
        <!-- 登录/注册 -->
        <div class="topRight">
          <div class="sign-box"  v-if="registerAndLoginDisabled">
            <router-link class="a globalLoginBtn" to="/login" rel="nofollow">登录</router-link>
            <router-link class="a register" to="/register" rel="nofollow">注册</router-link>
          </div>
          <div class="sign-box"  v-if="!registerAndLoginDisabled">
            <a class="a globalLoginBtn" @click="loginOut" rel="nofollow">退出</a>
            <router-link class="a globalLoginBtn" to="/" rel="nofollow">个人中心</router-link>
          </div>
        </div>
        <!-- 登录/注册 End -->
      </div>
    </div>
    <!-- top头部 End -->
    <div class="top-yxw-pc-gl"></div>
  </div>
</template>

<script>
export default {
  name: "HeadContainer",
  data(){
    return {
      registerAndLoginDisabled: true
    }
  },
  methods: {
    loginOut() {
      //把 token 清除
      localStorage.removeItem("token");
      // this.$router.push({path: "/index"})
      alert("退出成功....");
      //页面刷新
      location.reload();
    }
  },
  created() {
      const token = localStorage.getItem("token");
      if (token) {
        this.registerAndLoginDisabled = false;
      }
  }
}
</script>
<style src="@/assets/css/v2_index.css" scoped></style>